package Q1;

import java.util.Scanner;

public class Main2 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        int K = 0;
        int count = 0; //当先这个口罩已经使用了多少天
        int p = 0; //当前使用的是第几个口罩
        int day = 0;
        while (p < n && k <= k) {
            if (K + arr[p] * (int)Math.pow(2, count) > k) {
                p++;
                count = 0;
            }
            if (p < n) {
                K += arr[p] * (int)Math.pow(2, count++);
                day++;
            }
        }

        System.out.println(day);
    }
}
